package com.heima.admin.controller.v1;

import com.heima.admin.service.AdSensitiveService;
import com.heima.apis.admin.AdSensitiveControllerApi;
import com.heima.model.admin.dtos.SensitiveDto;
import com.heima.model.admin.pojos.AdSensitive;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/api/v1/sensitive")
public class AdSensitiveServiceController implements AdSensitiveControllerApi {
    @Resource
    private AdSensitiveService adSensitiveService;

    /**
     * 分页查询
     * @param sensitiveDto
     * @return
     */
    @PostMapping("/list")
    @Override
    public ResponseResult findByPageAndName(@RequestBody SensitiveDto sensitiveDto) {
        return adSensitiveService.findByPageAndName(sensitiveDto);
    }

    /**
     * 添加敏感词
     * @param adSensitive
     * @return
     */
    @PostMapping("/save")
    @Override
    public ResponseResult insert(@RequestBody AdSensitive adSensitive) {
        return adSensitiveService.insert(adSensitive);
    }

    /**
     * 修改敏感词
     * @param adSensitive
     * @return
     */
    @PostMapping("/update")
    @Override
    public ResponseResult updates(@RequestBody AdSensitive adSensitive) {
        return adSensitiveService.updates(adSensitive);
    }

    /**
     * 删除敏感词
     * @param id
     * @return
     */
    @DeleteMapping("/del/{id}")
    @Override
    public ResponseResult delete(@PathVariable("id") Integer id) {
        return adSensitiveService.delete(id);
    }
}
